<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="数据库备份" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<script language="javascript">
	function checkBackup(){
		var xmlHttp=createXMLHttpRequest();
		xmlHttp.open("GET", "/system/DbBackupCheck.ihtm?id=${id}");
		xmlHttp.onreadystatechange = function(){callback(xmlHttp)};
		xmlHttp.send(null);
	}
	function callback(xmlHttp){
    	if (xmlHttp.readyState == 4) {
      		if (xmlHttp.status == 200) {
      			var resText=xmlHttp.responseText;
      			var arr=resText.split(";");
      			var completeFlag="N";
      			var fizeSize="0";
      			if(arr.length>0){
      				completeFlag=arr[0];
      			}
      			if(arr.length>1){
      				fizeSize=arr[1];
      			}
      			var sizeStr="";
      			if((fizeSize-0)>1024*1024){
      				sizeStr=(fizeSize-0)/(1024*1024)+"";
      				sizeStr=sizeStr.split(".")[0]+"M";
      			}else{
      				sizeStr=(fizeSize-0)/1024+"";
      				sizeStr=sizeStr.split(".")[0];
      				if(sizeStr=="0"){
      					sizeStr="";
      				}else{
      					sizeStr=sizeStr+"K";
      				}
      			}
      			document.getElementById("fileSizeSpan").innerHTML=sizeStr;
      			if(completeFlag!="Y" && completeFlag!="F"){
      				setTimeout("checkBackup()",1000);
      			}else{
      				var showMsg="${showMsg}";
      				if(showMsg=='1'){
      					if(completeFlag=="F"){
      						document.getElementById("msgSpan").innerHTML="备份失败！有可能是杀毒软件导致，请检查您的设置．";
      					}else{
      						document.getElementById("msgSpan").innerHTML="备份完成！";
      					}
      				}else{
      					doCancel();
      				}
      			}
			}
		}
	}
	function doCancel(){
		parent.ClosePop();
	}
	function doInit(){
		document.getElementById("mainTbl").style.height=document.documentElement.clientHeight+"px";
	}
</script>
</head>
<body oncontextmenu="return false" onLoad="doInit();checkBackup();"  class="sheet">
	<table width="98%" height="100%" align="center" border="0" cellpadding="1" cellspacing="1" id="mainTbl">
		<tr> 
		    <td align="center">
		    	<span id="msgSpan">
		    	<img src="/images/wait.gif">
		    	<div class="blank12"></div>
		    		正在备份中，请稍候...
		    	</span>
		    	<span id="fileSizeSpan"></span>
				<div class="blank24"></div>
				<input type="button" class="buttom-a" onClick="doCancel();" value=" 关 闭 ">
			</td>
		</tr>
	</table>

</body>
</html>